home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
ab20
/
ab20_archive
/
utilities
/
arexx
/
rexxtra12.lzh
/
rexx
/
Clips.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1990-03-18
|
2KB
|
92 lines
/* Clips.rexx */
/*
Format
CLIPS [SAVE | {RECALL|LOAD}] [LIST] [FILE <name>]
List all elements in the ARexx clips list, or save or recall the
clips list. This allows saving of clips list entries from session
to session.
*/
facility = 'Clips'
retcode = 0
/* add our own functions to ARexx */
call addlib 'rexxextra.library',-20,-30,0
args. = ''
args.FILE = 's:Clips.dat'
template = "SAVE/S,LOAD=RECALL/S,LIST/S,FILE/K"
dtemplate = template
parse arg g_c
do while g_c='?'
options prompt dtemplate': ' /* this template is */
parse pull g_c /* displayed to the user */
if g_c='?' then do
g_s=sourceline(3)
if pos('/*',g_s)=0 then break; if pos('*/',g_s)>0 then break
say
g_s=sourceline(4)
do i=5 while pos('*/',g_s)=0; say g_s; g_s=sourceline(i); end
say
end
end
interpret Cparse(g_c,template,'args')
if args.ERRCODE > 1 then do; say facility'-E-BADARGS,' args.ERRTEXT; exit 5; end
if ~args.SAVE & ~args.LOAD then args.LIST = 1
if args.SAVE then retcode = max(retcode,saveclips())
if args.LOAD then retcode = max(retcode,recallclips())
if args.LIST then retcode = max(retcode,listclips())
exit retcode
listclips:
width = (screencols()-30)%8
namewidth = 20
trailer = '1B'x || '[0m'
a = sortwords(show('c'))
do c = 1 to words(a)
b = word(a,c)
d = getclip(b)
if length(d) > width-namewidth-1 then
d = substr(d,1,width-namewidth-4) || '...'
say left(b,namewidth) d || trailer
end
return 0
saveclips:
if ~open('cfile',args.FILE,'W') then do
say facility'-E-OPENIN, Error writing to file' args.FILE
return 10
end
a = sortwords(show('c'))
do c = 1 to words(a)
b = word(a,c)
d = getclip(b)
call writeln('cfile',b)
call writeln('cfile',d)
end
call close('cfile')
return 0
recallclips:
if ~open('cfile',args.FILE,'R') then do
say facility'-E-NOTFND,' args.FILE 'not found.'
return 10
end
b = readln('cfile')
do while ~eof('cfile')
d = readln('cfile')
if b ~= '' & d ~= '' then
if ~setclip(b,d) then
say facility'-W-NOTSET, Clip entry "'b'" could not be set'
b = readln('cfile')
end
call close('cfile')
return 0